import * as YvanUI from "yvan-ui-wotu"
import {DemoDialogBasic} from "./DemoDialogBasic";

let i = 0

interface Ref {
}

export default class DemoDialog extends YvanUI.Scope<void, Ref> {

    clickDialogBasic(sender) {
        new DemoDialogBasic({
            mode: 'new',
            success() {
                YvanUI.notifySuccess('外部收到消息')
            }
        }).showDialog(sender)
    }

    clickDialogBasicDrawer(sender) {
        new DemoDialogBasic({
            mode: 'new',
            success() {
                YvanUI.notifySuccess('外部收到消息')
            }
        }).showDrawer(sender)
    }

    clickDialogBasicPage() {
        new DemoDialogBasic({
            mode: 'new',
            success() {
                YvanUI.notifySuccess('外部收到消息')
            }
        }).showPage('demoDialog')
    }

    clickShowConfirm() {
        YvanUI.confirm('确定要删除这3条数据?').then(() => {
            YvanUI.notifySuccess("删除成功")
        }).catch(() => {
            YvanUI.notifyInfo("取消删除")
        })
    }

    clickShowConfirmWithPromise() {
        YvanUI.confirm('确定要删除吗？', () => new Promise(resolve => {
            setTimeout(() => {
                resolve('OK')
            }, 3000)
        }))
    }

    clickShowLoading() {
        YvanUI.loading('正在加载中...')
    }

    clickClearLoading() {
        YvanUI.clearLoading()
    }

    clickShowSuccessDialog() {
        YvanUI.showSuccessDialog('成功消息');
    }

    clickShowWarningDialog() {
        YvanUI.showWarningDialog('警告消息');
    }

    clickShowInfoDialog() {
        YvanUI.showInfoDialog('普通消息');
    }

    clickShowErrorDialog() {
        YvanUI.showErrorDialog('错误消息');
    }

    clickShowSuccess() {
        YvanUI.showSuccess('成功消息')
    }

    clickShowWarning() {
        YvanUI.showWarning('警告消息')
    }

    clickShowInfo() {
        YvanUI.showInfo('普通消息')
    }

    clickShowError() {
        YvanUI.showError('错误消息')
    }

    clickNotifySuccess() {
        YvanUI.notifySuccess('成功通知')
    }

    clickNotifyWarning() {
        YvanUI.notifyWarning('警告通知')
    }

    clickNotifyInfo() {
        YvanUI.notifyInfo('普通通知')
    }

    clickNotifyError() {
        YvanUI.notifyError('错误通知')
    }

    vjson = {
        view: 'page',
        title: '对话框演示',
        // title: <div><span style={{color: 'RED'}}>{this.className}</span></div>,
        subTitle: '展示一些对话框操作',
        items: [
            {
                view: 'card',
                items: [
                    {
                        view: 'space',
                        style: {'width': '100%', 'paddingBottom': '10px', 'paddingLeft': '10px'},
                        items: [
                            {
                                view: 'button',
                                text: 'ShowSuccess',
                                onClick: this.clickShowSuccess
                            },
                            {
                                view: 'button',
                                text: 'ShowWarning',
                                onClick: this.clickShowWarning
                            },
                            {
                                view: 'button',
                                text: 'ShowInfo',
                                onClick: this.clickShowInfo
                            },
                            {
                                view: 'button',
                                text: 'ShowError',
                                onClick: this.clickShowError
                            },
                            {
                                view: 'button',
                                text: 'ShowLoading',
                                onClick: this.clickShowLoading
                            },
                            {
                                view: 'button',
                                text: 'ClearLoading',
                                onClick: this.clickClearLoading
                            },
                        ]
                    },
                    {
                        view: 'space',
                        style: {'width': '100%', 'paddingBottom': '10px', 'paddingLeft': '10px'},
                        items: [
                            {
                                view: 'button',
                                text: 'ShowSuccessialog',
                                onClick: this.clickShowSuccessDialog
                            },
                            {
                                view: 'button',
                                text: 'ShowWarningDialog',
                                onClick: this.clickShowWarningDialog
                            },
                            {
                                view: 'button',
                                text: 'ShowInfoDialog',
                                onClick: this.clickShowInfoDialog
                            },
                            {
                                view: 'button',
                                text: 'ShowErrorDialog',
                                onClick: this.clickShowErrorDialog
                            },
                            {
                                view: 'button',
                                text: 'ShowConfirm',
                                onClick: this.clickShowConfirm
                            },
                            {
                                view: 'button',
                                text: 'ShowConfirmWithPromise',
                                onClick: this.clickShowConfirmWithPromise
                            }
                        ]
                    },
                    {
                        view: 'space',
                        style: {'width': '100%', 'paddingBottom': '10px', 'paddingLeft': '10px'},
                        items: [
                            {
                                view: 'button',
                                text: 'NotifySuccess',
                                onClick: this.clickNotifySuccess
                            },
                            {
                                view: 'button',
                                text: 'NotifyWarning',
                                onClick: this.clickNotifyWarning
                            },
                            {
                                view: 'button',
                                text: 'NotifyInfo',
                                onClick: this.clickNotifyInfo
                            },
                            {
                                view: 'button',
                                text: 'NotifyError',
                                onClick: this.clickNotifyError
                            }
                        ]
                    },
                    {
                        view: 'space',
                        style: {'width': '100%', 'paddingBottom': '10px', 'paddingLeft': '10px'},
                        items: [
                            {
                                view: 'button',
                                text: '基本对话框',
                                onClick: this.clickDialogBasic
                            },
                            {
                                view: 'button',
                                text: '基本抽屉',
                                onClick: this.clickDialogBasicDrawer
                            },
                            {
                                view: 'button',
                                text: '基本页面',
                                onClick: this.clickDialogBasicPage
                            }
                        ]
                    }
                ]
            }
        ]
    }
}